﻿using System;
using System.Collections.Generic;
using System.Text;
using rkShared.Serialization;
using rkShared.BEncode;

namespace rkShared
{
    public class Snapshot:IBinarySerializable
    {
        public List<Player> Players { get; set; }

        public Snapshot()
        {
            this.Players = new List<Player>();
        }

        #region IBinarySerializable Members

        public void SerializeToDictionary(rkShared.BEncode.BEncodedDictionary dictionary)
        {
            BEncodedList _list = new BEncodedList();
            foreach (Player p in this.Players)
                _list.Add(p);
            dictionary.Add("p", _list);
        }
        public void DeserializeFromDictionary(rkShared.BEncode.BEncodedDictionary dict)
        {
            BEncodedList _list = dict["p"] as BEncodedList;
            foreach (BEncodedDictionary d in _list)
            {
                Player p = new Player();
                p.DeserializeFromDictionary(d);
                this.Players.Add(p);
            }
        }

        #endregion
    }
}
